<?php
/*
 * Template Name: pro_list
 */
?>

<?php
get_header();
?>



<div class="page2 pro-list">
  <div class="wrap clearfix">
    <div class='pro-list-wrap clearfix' id="article-list">

<?php
$paged          = (get_query_var('paged')) ? get_query_var('paged') : 1;
$posts_per_page = get_category(get_query_var('cat'))->category_parent == 0 ? 999 : 999;

// exit;
$args = array(
    'caller_get_posts' => 1,
    'cat'              => get_query_var('cat'),
    'paged'            => $paged,
    'posts_per_page'   => $posts_per_page,
);
query_posts($args);
while (have_posts()) {
    the_post();
    ?>
      

     <div class="pro-item article-item">
       <a href="<?php echo home_url('index.php/detail/?post_id=' . $post->ID); ?>" class='link-wrap'>
         <div class="pic-wrap">
            <?php if (has_post_thumbnail()) {
            the_post_thumbnail('pro');
        } else {?>
                <img src="<?php bloginfo('template_url');?>/images/dot.jpg" alt="..." />
            <?php }?>
          </div>
          <div class="title"><?php the_title();?></div>
          <div class='desc'>
            <?php echo get_post_meta($post->ID, 'desc', true); ?>
          </div>
       </a>
    </div>
<?php

}
?>
</div>
<?php 

wp_reset_query();
?>
  </div>
</div>

<script>
$('loading')

$('.article-paging > a').on('click',function(){ //点击实现加载更多，你可以根据自己需要改成下拉自动加载
 var next_url = $(this).attr("href");
 var next_text = $(this).text();
 $.ajax({
 type: 'get',
 url: next_url + '#article-list',
 success: function(data){
 result = $(data).find("#article-list .article-item");
 next_link = $(data).find(".article-paging > a").attr("href");
 //$(this).attr("href", next_url);
 if (next_link != undefined){
 $('.article-paging > a').attr("href", next_link);
 }else{
 $(".loading-more").remove();
 }

console.log(result);
$(function(){
 $("#article-list").append(result.css({display: 'inline-block'}).fadeIn(300));
 $('.thumb').lazyload({
 data_attribute: 'src',
 placeholder: _BGJ.uri + '/static/img/thumbnail.png',
 threshold: 400
 });
 });

$(function() {
 if (next_url.indexOf("page") < 1) {
 $("#article-list").html('');
 }
 $("#article-list").append(result.fadeIn(200));
 });
 }
 });
 return false;
 });
</script>

<?php
get_footer();
?>